public class Demo12 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
           while(true){
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
        });

        System.out.println(t.getState());// New
        t.start();

        // 线程正在运行过程中或者是正在等待运行就是 RUNNABLE
        for(int i = 0;i < 5;i++){
            // 第一次还未执行上面的sleep是RUNNABLE
            // 后面有固定时间的阻塞了都是TIMED_WAITING
            System.out.println(t.getState());
            Thread.sleep(1000);
        }

        t.join();
        // t对象还在,但是t线程已经结束了
        System.out.println(t.getState());// TERMINATED
    }
}
